import {
    reqRecommendSongs,
    reqNewSongs,
    reqRecommendSongsCommit,
    reqRecommendSongsDetail
    
} from "../../api/home";

const state = {
    recommendSongs: [],
    newSongs: [],
    recommendSongsCommit: [],//获取歌单评论
    recommendSongsDetail:[],//获取歌单列表
};

const actions = {
    async getRecommendSongs({
        commit
    }, limit) {
        let res = await reqRecommendSongs(limit);
        if (res.data.code == 200) {
            commit("GETRECOMMENDSONGS", res.data.result);
        }
    },
    async getNewSongs({
        commit
    }, limit) {
        let res = await reqNewSongs(limit);
        if (res.data.code == 200) {
            commit('GETNEWSONGS', res.data.result);
        }
    },
    async getRecommendSongsDetail({ commit }, id) {
        let res = await reqRecommendSongsDetail(id);
        if (res.data.code == 200) {
            // commit('GETRECOMMENDSONGSDETAIL', res.data.result);
        }
    },
    async getRecommendSongsCommit({ commit }, id) {
        let res = await reqRecommendSongsDetail(id);
        if (res.data.code == 200) {
            // commit('GETRECOMMENDSONGSCOMMIT', res.data.result);
        }
    }
};

const mutations = {
    GETRECOMMENDSONGS(state, data) {
        state.recommendSongs = data;
    },
    GETNEWSONGS(state, data) {
        state.newSongs = data;
    },
    GETRECOMMENDSONGSDETAIL(state, data) {
        state.recommendSongsDetail = data;
    },
    GETRECOMMENDSONGSCOMMIT(state, data) {
        state, recommendSongsCommit = data;
    }
};

export default {
    state,
    actions,
    mutations
}